package com.jyu.hakkatranslation.service.Impl;

import com.jyu.hakkatranslation.dao.SingleWordMapper;
import com.jyu.hakkatranslation.pojo.SingleWord;
import com.jyu.hakkatranslation.service.SingleWordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SingleWordServiceImpl implements SingleWordService {
    @Autowired
    SingleWordMapper singleWordMapper;
    @Override
    public SingleWord SelectWordOneBuOne(String mandarin) {
        SingleWord singleWord = singleWordMapper.SelectWordOneBuOne(mandarin);
        return singleWord;
    }
    public String SelectByAllSentence(String Sentence){
        String result="";
        for(int i=0;i<Sentence.length()-1;i++){
            System.out.println(Sentence.charAt(i));
            String one=Sentence.substring(i,i+1);
            SingleWord singleWord = singleWordMapper.SelectWordOneBuOne(one);

            result=result+singleWord.getPronunciation()+" ";
        }
        return result;
    }

    @Override
    public List<SingleWord> SelectAllWord() {
        List<SingleWord> singleWords = singleWordMapper.SelectAllWord();
        return singleWords;
    }

}
